package org.rico.hibernate.validator.helloworld.classlevel;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * This class is used to verify Account and verify that the date of birth is
 * properly set. This validator respsects the list of fields allowed to be in a
 * shell account.
 * 
 * @author cexell
 * 
 */
public class CheckDateOfBirthValidator implements ConstraintValidator<CheckDateOfBirth, Account> {

	public void initialize(final CheckDateOfBirth constraintAnnotation) {
	}

	public boolean isValid(final Account acctObj, final ConstraintValidatorContext context) {
		boolean retVal = true;

		context.buildConstraintViolationWithTemplate("{date_of_birth_required.default}").addNode("date_of_birth")
				.addConstraintViolation();
		context.disableDefaultConstraintViolation();
		return retVal;
	}
}
